import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		uerInfo: {},
		hasLogin: false,
		idx:''  ,//专项评测的序列用于再测一次
		idxs:'' ,//健康调查的序列
		testType:'' ,//评测类型
		yyname:'' ,//孕妇预约的名字
		sqname:'' ,//存放社区的名字
		birthday:'',
		heights:'',//信封条的状态
		newsqname:''  ,//编辑信息的最终社区
		errorcode:'' //错误代号
	},
	mutations: {
		loginsave(state, provider) {
			// console.log(provider)
			state.hasLogin = true
			state.userInfo = provider;
			uni.setStorage({
				key: 'uerInfo',
				data: provider
			})
			uni.setStorage({
				key: 'loginstate',
				data: true
			})
			//console.log(state.userInfo)
		},
		//彻底退出清空key
		logout(state) {
			state.hasLogin = false
			state.uerInfo = {}
			uni.removeStorage({
				key: 'uerInfo'
			});
			uni.removeStorage({
				key: 'community'
			});
			uni.setStorage({
				key: 'loginstate',
				data: false
			})
		}
	}
})

export default store
